****What follows are the Stata commands necessary to produce all of the tables in the article. Before running the commands, convert all datasets into Stata format, or otherwise infile them at the relevant command. Also include the relevant file path information for each dataset.


****to produce Table 1
use "votes.dta"
merge m:1 congress state_icpsr using "populations.dta"
drop _merge
gen yesvote = cast_code
recode yesvote (1=1) (6=0) (else=.)
gen novote=cast_code
recode novote (6=1) (1=0) (else=.)
gen yespop= (yesvote * population)/2
gen nopop= (novote * population)/2
collapse (sum) yesvote novote yespop nopop, by(congress rollnumber)
gen cmy=0
replace cmy=1 if (yesvote > novote) & (yespop< nopop)
gen cmn=0
replace cmn=1 if (novote >=yesvote) & (yespop>nopop)
gen cm = cmy+cmn
collapse (mean) cm, by(congress)
merge 1:1 congress using "independent_vars.dta"
drop _merge
sort congress
tset congress 
generate newcm=d.cm
generate newgini=d.gini
generate newclosevote=d.closevote
generate newmajfrac=d.majfrac
regress newcm newgini
outreg2 using test.doc,dec(2)
regress newcm newclosevote
outreg2 using test.doc, dec(2) append
regress newcm newmajfrac
outreg2 using test.doc, dec(2) append
regress newcm newgini newclosevote  newmajfrac
outreg2 using test.doc, dec(2) append
estat dwatson
dfuller newcm, noconstant lags(1)
dfuller newgini, noconstant lags(1)
dfuller newclosevote, noconstant lags(1)
dfuller newmajfrac, noconstant lags(1)
*repeating the Dicky-Fuller tests with different lags (2, 3, and 4) likewise allows rejection of the null hypopthesis that the differenced variables are nonstationary.

*to demonstrate that the primary takeaway from Table 1 holds when variables remain as levels and are not differenced (noted, not reported).
regress cm gini
regress cm closevote
regress cm majfrac
regress cm gini closevote majfrac
clear


****to produce Table 2
use "votes.dta"
merge m:1 congress state_icpsr using "populations.dta"
drop _merge
gen yesvote = cast_code
recode yesvote (1=1) (6=0) (else=.)
gen novote=cast_code
recode novote (6=1) (1=0) (else=.)
gen yespop= (yesvote * population)/2
gen nopop= (novote * population)/2
collapse (sum) yesvote novote yespop nopop, by(congress rollnumber)
gen cmy=0
replace cmy=1 if (yesvote > novote) & (yespop< nopop)
gen cmn=0
replace cmn=1 if (novote >=yesvote) & (yespop>nopop)
gen cm = cmy+cmn
merge 1:1 congress rollnumber using "motions.dta"
drop _merge
keep if supermaj==0 & invoke > 0
keep if yesvote > novote & yesvote <60
gen counter=.
replace counter=1 if yespop>nopop
replace counter=0 if nopop>yespop
tab congress counter, row
clear


******to produce Table 3
use "votes.dta"
merge m:1 congress state_icpsr using "populations.dta"
drop _merge
gen yesvote = cast_code
recode yesvote (1=1) (6=0) (else=.)
gen novote=cast_code
recode novote (6=1) (1=0) (else=.)
gen yespop= (yesvote * population)/2
gen nopop= (novote * population)/2
collapse (sum) yesvote novote yespop nopop, by(congress rollnumber)
gen cmy=0
replace cmy=1 if (yesvote > novote) & (yespop< nopop)
gen cmn=0
replace cmn=1 if (novote >=yesvote) & (yespop>nopop)
gen cm = cmy+cmn
drop if congress < 79
merge 1:1 congress rollnumber using "motions.dta"
keep if _merge==3
drop _merge
tab motiontype if cm==1
*Frequency entries are the first data column in Table 3. Percent entries are the second data column.
tab motiontype cm, row
*Percentages for cm==1 are the third data column.
tab motiontype if cm==1 & keyvote==1
*Frequency entries are the fourth data column in Table 3. Percent entries are the fifth data column.
tab motiontype cm, row, if keyvote==1
*Percentages for cm==1 are the sixth data column.

*to list all 911 keyvote measures and the 438 with at least one countermajoritarian roll call (referenced in the paragraph setting up Table 4).
sort congress
drop if keymeasure==0
by congress: tab keyid
by congress: tab keyid if cm==1
clear
